"JUNE Listing 4" as saved on disk
0800              1           TTL "SPEED/ASM Sample program"
0800              2  ;
0800              3  ;
0800              4  ;
0800              5  ;****************************************
0800              6  ;*                                      *
0800              7  ;*      SPEED/ASM Equates               *
0800              8  ;*                                      *
0800              9  ;****************************************
0800             10  ;
0800             11  ;
0800             12  ;
0800             13  ;
0800             14  ;
0800             15  ;
0800             16  ;
0800             17  ;
0800             18  ; GENERAL PURPOSE EQUATES
0800             19  ;
0800             20  ; The following variable are used
0800             21  ; by the SPEED/ASM package
0800             22  ; and shouldn't be used by the SPEED/ASM
0800             23  ; programmer.
0800             24  ;
0800             25  ;
0800             26  ;
0800             27  ;
0000             28  FORASAV  EPZ 0
0001             29  FORXSAV  EPZ FORASAV+1
0002             30  FORYSAV  EPZ FORXSAV+1
0003             31  FORZPG   EPZ FORYSAV+1
0005             32  DESTADR  EPZ FORZPG+2
0007             33  PTRADR   EPZ DESTADR+2
0009             34  ISIMMED  EPZ PTRADR+2
000A             35  OP       EPZ ISIMMED+1
000C             36  MAXLEN   EPZ OP+2
000D             37  VALUE    EPZ MAXLEN+1
000F             38  DIGIT    EPZ VALUE+2
0010             39  LEAD0    EPZ DIGIT+1
0011             40  JMPADR   EPZ LEAD0+1
0013             41  COUNT    EPZ JMPADR+2
0014             42  GOTLN    EPZ COUNT+1
0015             43  LINEINDX EPZ GOTLN+1
0016             44  SIGN     EPZ LINEINDX+1
0017             45  ACL      EPZ SIGN+1
0018             46  ACH      EPZ ACL+1
0019             47  XTNDL    EPZ ACH+1
001A             48  XTNDH    EPZ XTNDL+1
001B             49  AUXL     EPZ XTNDH+1
001C             50  AUXH     EPZ AUXL+1
0800             51  ;
0033             52  PROMPT   EPZ $33
004E             53  RNDL     EPZ $4E
004F             54  RNDH     EPZ $4F
0100             55  STACK    EQU $100
0200             56  INPUT    EQU $200
0800             57  ;
0800             58  ;
0800             59  ;
0800             60  ;
0800             61  ;
0800             62  ;
0800             63  ;
0800             64  ;****************
0800             65  ;*  CONSTANTS   *
0800             66  ;****************
0800             67  ;
0800             68  ;
0800             69  ;
0800             70  ; The following symbols are constants
0800             71  ; for the values "FALSE", "TRUE", and
0800             72  ; Carriage Return (respectively).
0800             73  ;
0800             74  ; These symbols should only appear
0800             75  ; as immediate operands to a 6502
0800             76  ; instruction or in the operand field
0800             77  ; of a pseudo-opcode like BYT.
0800             78  ;
0800             79  ;
0800             80  ;
0800             81  ;
0800             82  ;
0000             83  FALSE    EQU 0
0001             84  TRUE     EQU 1
008D             85  CR       EQU $8D
0800             86  ;
0800             87  ;
0800             88  ;
0800             89  ;
0800             90  ;
0800             91  ;
0800             92  ; "IF" STATEMENT EQUATES
0800             93  ;
0800             94  ; The following symbols should only
0800             95  ; be used in the ADR pseudo-opcode
0800             96  ; following a call to the SPEED/ASM
0800             97  ; IFx routines.
0800             98  ;
0800             99  ;
0800            100  ;
00BD            101  EQ       EQU "="
00A3            102  NE       EQU "#"
00BE            103  GT       EQU ">"
00BC            104  LT       EQU "<"
BDBE            105  GE       EQU ">"|"="*256
BDBC            106  LE       EQU "<"|"="*256
0800            107  ;
0800            108  ;
0800            109  ;
0800            110  ;
0800            111  ;
0800            112  ;
0800            113  ;
0800            114  ;***************************
0800            115  ;* SPEED/ASM ENTRY POINTS  *
0800            116  ;***************************
0800            117  ;
0800            118  ;
0800            119  ;
0800            120  ;
0800            121  ; NOTE: THE EQUATE OF PUTC MUST
0800            122  ; BE CHANGED IF YOU RELOCATE
0800            123  ; SPEED/ASM TO SOME LOCATION
0800            124  ; OTHER THAN $7800
0800            125  ;
0800            126  ;
0800            127  ;
7800            128  PUTC     EQU $7800
7803            129  GETC     EQU PUTC+3
7806            130  SAGL     EQU GETC+3          ;FOR USE BY S/A ONLY- SEE DOC.
7809            131  SAPC     EQU SAGL+3          ; "   "   "  "   "     "   "
780C            132  HOME     EQU SAPC+3          ;HOME AND CLEAR
780F            133  READLN   EQU HOME+3
7812            134  INIT     EQU READLN+3
7815            135  FOR      EQU INIT+3
7818            136  FOR0     EQU FOR+3
781B            137  NEXT     EQU FOR0+3
781E            138  IFI      EQU NEXT+3
7821            139  IFI0     EQU IFI+3
7824            140  IFS      EQU IFI0+3
7827            141  IFS0     EQU IFS+3
782A            142  MOVE     EQU IFS0+3
782D            143  LOAD     EQU MOVE+3
7830            144  MOVS     EQU LOAD+3
7833            145  LDSTR    EQU MOVS+3
7836            146  PRINT    EQU LDSTR+3
7839            147  PRTSTR   EQU PRINT+3
783C            148  PRTINT   EQU PRTSTR+3
783F            149  RDSTR    EQU PRTINT+3
7842            150  RDINT    EQU RDSTR+3
7845            151  ONXGOTO  EQU RDINT+3
7848            152  CASE     EQU ONXGOTO+3
784B            153  CASEI    EQU CASE+3
784E            154  INSET    EQU CASEI+3
7851            155  NOTINSET EQU INSET+3
7854            156  ABS      EQU NOTINSET+3
7857            157  NEG      EQU ABS+3
785A            158  MUL      EQU NEG+3
785D            159  DIV      EQU MUL+3
7860            160  MOD      EQU DIV+3
7863            161  RND      EQU MOD+3
7866            162  SUBSTR   EQU RND+3
7869            163  INDEX    EQU SUBSTR+3
786C            164  LENGTH   EQU INDEX+3
786F            165  CONCAT   EQU LENGTH+3
7872            166  GETWZPG  EQU CONCAT+3        ;USED BY SPEED/ASM
7875            167  RDFP     EQU GETWZPG+3
7878            168  PRTE     EQU RDFP+3
787B            169  PRTF     EQU PRTE+3
787E            170  FADD     EQU PRTF+3
7881            171  FSUB     EQU FADD+3
7884            172  FMUL     EQU FSUB+3
7887            173  FDIV     EQU FMUL+3
788A            174  FLT      EQU FDIV+3
788D            175  FIX      EQU FLT+3
7890            176  FNEG     EQU FIX+3
7893            177  FADDTN   EQU FNEG+3
7896            178  FSUBTN   EQU FADDTN+3
7899            179  FTIMES   EQU FSUBTN+3
789C            180  FINTO    EQU FTIMES+3
789F            181  IFF      EQU FINTO+3
78A2            182  MOVFP    EQU IFF+3
0800            183  ;
0800            184  ;
0800            185  ;
0800            186  ;**********************************
0800            187  ;*                                *
0800            188  ;* SPEED/ASM Sample program #3:   *
0800            189  ;*                                *
0800            190  ;*  This program demonstrates     *
0800            191  ;* some 6502 code that is neces-  *
0800            192  ;* sary for writing SPEED/ASM     *
0800            193  ;* programs. In particular it     *
0800            194  ;* demonstrates how one handles   *
0800            195  ;* character variables in a       *
0800            196  ;* SPEED/ASM program.             *
0800            197  ;*                                *
0800            198  ;* Assembler: LISA 2.5            *
0800            199  ;* Requires SPEED/ASM package.    *
0800            200  ;* Randall Hyde                   *
0800            201  ;*                                *
0800            202  ;**********************************
0800            203  ;
0800            204  ;
0800            205  ;
0800            206  ;
0800            207  ;
FF69            208  EXIT     EQU $FF69           ; Entry point to Apple Monitor.
0800            209  ;
0800            210  ;
0800            211  ;
0800 20 12 78   212           JSR INIT            ; Initialize SPEED/ASM
0803            213  ;
0803            214  ;
0803 20 0C 78   215           JSR HOME            ; Clear the Screen
0806 20 36 78   216           JSR PRINT
0809 8D 8D B6   217           BYT CR,CR,"6502--SPEED/ASM Test Program"
080C B5 B0 B2 
080F AD AD D3 
0812 D0 C5 C5 
0815 C4 AF C1 
0818 D3 CD A0 
081B D4 E5 F3 
081E F4 A0 D0 
0821 F2 EF E7 
0824 F2 E1 ED 
0827 8D 8D      218           BYT CR,CR
0829 C1 D3 C3   219           BYT "ASCII Character Set Table",CR
082C C9 C9 A0 
082F C3 E8 E1 
0832 F2 E1 E3 
0835 F4 E5 F2 
0838 A0 D3 E5 
083B F4 A0 D4 
083E E1 E2 EC 
0841 E5 8D 
0843 AD AD AD   220           BYT "-------------------------"
0846 AD AD AD 
0849 AD AD AD 
084C AD AD AD 
084F AD AD AD 
0852 AD AD AD 
0855 AD AD AD 
0858 AD AD AD 
085B AD 
085C 8D 8D      221           BYT CR,CR
085E C3 E8 E1   222           BYT "Character   ASCII Code",CR
0861 F2 E1 E3 
0864 F4 E5 F2 
0867 A0 A0 A0 
086A C1 D3 C3 
086D C9 C9 A0 
0870 C3 EF E4 
0873 E5 8D 
0875 AD AD AD   223           BYT "---------   ----------",CR,CR,0
0878 AD AD AD 
087B AD AD AD 
087E A0 A0 A0 
0881 AD AD AD 
0884 AD AD AD 
0887 AD AD AD 
088A AD 8D 8D 
088D 00 
088E            224  ;
088E            225  ; Init CH to space
088E            226  ;
088E A9 A0      227           LDA #" "
0890 8D DA 09   228           STA CH
0893            229  ;
0893            230  ; Loop to print the ASCII values
0893            231  ;
0893 AD DA 09   232  PRTASC   LDA CH              ; Emulate the BASIC
0896 8D DB 09   233           STA I               ; statement "I = ASC(CH)
0899 A9 00      234           LDA #0
089B 8D DC 09   235           STA I+1
089E            236  ;
089E 20 36 78   237           JSR PRINT
08A1 A0 A0 A0   238           BYT "    ",0
08A4 A0 00 
08A6 AD DA 09   239           LDA CH              ;  Print the character
08A9 20 00 78   240           JSR PUTC
08AC 20 36 78   241           JSR PRINT
08AF A0 A0 A0   242           BYT "   -----  ",0
08B2 AD AD AD 
08B5 AD AD A0 
08B8 A0 00 
08BA 20 3C 78   243           JSR PRTINT          ; Print the ASCII Code
08BD DB 09      244           ADR I
08BF            245  ;
08BF            246  ;
08BF            247  ; Print a carriage return to
08BF            248  ; move to the next line.
08BF            249  ;
08BF A9 8D      250           LDA #CR
08C1 20 00 78   251           JSR PUTC
08C4            252  ;
08C4            253  ; Add one to the CH value
08C4            254  ;
08C4 EE DA 09   255           INC CH              ; 6502 instruction to increment a byte
08C7            256  ;
08C7            257  ; See if we're done
08C7            258  ;
08C7 AD DA 09   259           LDA CH
08CA C9 FF      260           CMP #$FF            ; Last ASCII value plus one
08CC 90 C5      261           BLT PRTASC
08CE            262  ;
08CE            263  ;
08CE            264  ;
08CE            265  ; Read characters from the keyboard
08CE            266  ; until a "#" character is pressed.
08CE            267  ;
08CE 20 36 78   268           JSR PRINT
08D1 8D 8D C5   269           BYT CR,CR,"Enter any text terminated",CR
08D4 EE F4 E5 
08D7 F2 A0 E1 
08DA EE F9 A0 
08DD F4 E5 F8 
08E0 F4 A0 F4 
08E3 E5 F2 ED 
08E6 E9 EE E1 
08E9 F4 E5 E4 
08EC 8D 
08ED E2 F9 A0   270           BYT "by a pound sign (""#"")",CR,CR
08F0 E1 A0 F0 
08F3 EF F5 EE 
08F6 E4 A0 F3 
08F9 E9 E7 EE 
08FC A0 A8 A2 
08FF A3 A2 A9 
0902 8D 8D 
0904 BA 00      271           BYT ":",0
0906 20 03 78   272  READLOOP JSR GETC            ; Read the character
0909 20 00 78   273           JSR PUTC            ; and print it.
090C C9 A3      274           CMP #"#"            ; Check for "#" character.
090E D0 F6      275           BNE READLOOP        ; If not "#", repeat.
0910            276  ;
0910            277  ;
0910            278  ; The following code prompts the
0910            279  ; person at the keyboard to enter
0910            280  ; "Y" or "N". If something else
0910            281  ; is entered then the code is
0910            282  ; repeated.
0910            283  ;
0910 20 36 78   284  GETYORN  JSR PRINT
0913 8D 8D 8D   285           BYT CR,CR,CR
0916 C5 EE F4   286           BYT "Enter Yes or No (Y/N): ",0
0919 E5 F2 A0 
091C D9 E5 F3 
091F A0 EF F2 
0922 A0 CE EF 
0925 A0 A8 D9 
0928 AF CE A9 
092B BA A0 00 
092E 20 03 78   287           JSR GETC
0931 C9 D9      288           CMP #"Y"
0933 F0 04      289           BEQ GOODANS
0935 C9 CE      290           CMP #"N"
0937 D0 D7      291           BNE GETYORN
0939            292  ;
0939            293  GOODANS:
0939            294  ;
0939            295  ;
0939            296  ;
0939            297  ; This code prompts the user to enter
0939            298  ; a decimal value. Once the value
0939            299  ; is entered the ASCII character
0939            300  ; corresponding to that code is
0939            301  ; printed on the screen.
0939            302  ;
0939            303  ;  Entering zero terminates the
0939            304  ; loop.
0939            305  ;
0939 20 36 78   306  PRTCHR   JSR PRINT
093C 8D         307           BYT CR
093D 8D C5 EE   308           BYT CR,"Enter a decimal value in the"
0940 F4 E5 F2 
0943 A0 E1 A0 
0946 E4 E5 E3 
0949 E9 ED E1 
094C EC A0 F6 
094F E1 EC F5 
0952 E5 A0 E9 
0955 EE A0 F4 
0958 E8 E5 
095A 8D F2 E1   309           BYT CR,"range 0..255: ",0
095D EE E7 E5 
0960 A0 B0 AE 
0963 AE B2 B5 
0966 B5 BA A0 
0969 00 
096A 20 42 78   310           JSR RDINT
096D DB 09      311           ADR I
096F 70 C8      312           BVS PRTCHR          ; If an error occured.
0971            313  ;
0971            314  ; Force integer value into the
0971            315  ; range 0..255 by zeroing the high
0971            316  ; order byte.
0971            317  ;
0971 A9 00      318           LDA #0
0973 8D DC 09   319           STA I+1
0976            320  ;
0976            321  ; Print the decimal value (in case
0976            322  ; they entered too large a number,
0976            323  ;
0976 20 36 78   324           JSR PRINT
0979 8D C4 E5   325           BYT CR,"Decimal value: ",0
097C E3 E9 ED 
097F E1 EC A0 
0982 F6 E1 EC 
0985 F5 E5 BA 
0988 A0 00 
098A 20 3C 78   326           JSR PRTINT
098D DB 09      327           ADR I
098F 20 36 78   328           JSR PRINT
0992 A0 A0 C1   329           BYT "  ASCII Character: """,0
0995 D3 C3 C9 
0998 C9 A0 C3 
099B E8 E1 F2 
099E E1 E3 F4 
09A1 E5 F2 BA 
09A4 A0 A2 00 
09A7 AD DB 09   330           LDA I
09AA 20 00 78   331           JSR PUTC
09AD A9 A2      332           LDA #"""
09AF 20 00 78   333           JSR PUTC
09B2            334  ;
09B2            335  ; Check the L.O. byte of I to
09B2            336  ; see if it is zero.
09B2            337  ;
09B2            338  ; (On the '6502 BEQ and BNE can
09B2            339  ; be used immediately after a
09B2            340  ; LDA instruction to see if zero
09B2            341  ; was loaded into the accumlator
09B2            342  ; or not)
09B2            343  ;
09B2 AD DB 09   344           LDA I
09B5 D0 82      345           BNE PRTCHR
09B7            346  ;
09B7            347  ;
09B7            348  ; Quit and return to the Apple Monitor
09B7            349  ;
09B7 20 36 78   350           JSR PRINT
09BA 8D 8D 8D   351           BYT CR,CR,CR
09BD C5 EE E4   352           BYT "End of sample program #3",CR,0
09C0 A0 EF E6 
09C3 A0 F3 E1 
09C6 ED F0 EC 
09C9 E5 A0 F0 
09CC F2 EF E7 
09CF F2 E1 ED 
09D2 A0 A3 B3 
09D5 8D 00 
09D7            353  ;
09D7            354  ;
09D7 4C 69 FF   355           JMP EXIT            ;  Return to Apple Monitor
09DA            356  ;
09DA            357  CH       DFS 1               ; Char
09DB            358  I        DFS 2               ; Integer
09DD            359           END 